package com.work.leecode.array.difficult;

/**
 * 盛水最多的容器---11
 */
public class Lc11 {
    //双指针---每次移动小边
    public int maxArea(int[] height) {
        if (height == null || height.length == 0) {
            return 0;
        }

        int left = 0, right = height.length - 1;
        int maxArea = 0;
        while (left < right) {
            if (height[left] < height[right]) {
                maxArea = Math.max(height[left] * (right - left), maxArea);
                left++;
            } else {
                maxArea = Math.max(height[right] * (right - left), maxArea);
                right--;
            }
        }
        return maxArea;
    }
}
